﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace King.Extensions {
    public class AssertException : Exception {
        private string m_path;
        private int? m_line;

        internal AssertException(string path, int? line) {
            m_path = path;
            m_line = line;
        }

        public override string Message {
            get { return ToString(); }
        }

        public override string ToString() {
            return "Assert failed in file " + m_path + " at line " + m_line + ".";
        }
    }
    public class ASSERT {
        public static void Condition(bool assertion, [CallerFilePath]string path = null, [CallerLineNumber]int? line = null) {
            if (!assertion)
                throw new AssertException(path, line);
        }
        public static void Unreachable([CallerFilePath]string path = null, [CallerLineNumber]int? line = null) {
            Condition(false, path, line);
        }
    }
}
